<?php
/*
 * @Author: your name
 * @Date: 2021-09-21 16:46:35
 * @LastEditTime: 2021-12-31 14:37:31
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /nlog/app/Http/Controllers/AdminController/Login.php
 */

namespace App\Http\Controllers\admin_controller;

use Illuminate\Support\Facades\Request;
use App\Models\admin_model\Housing as HousingDb;
class Housing extends BaseController
{
    
    public function housingAdd()
    {
       return  redis_mysql_add('housing');
    }

    public function housingEdit()
    {
        return  redis_mysql_edit('housing');
    }


    public function housingSelOne()
    {
        return  redis_mysql_selone('housing');
    }

    public function housingBatchEdit(){
        if(Request::has('id') && Request::has('formData')){
            $res = redis_mysql_edit_in('housing', Request::input('id'), Request::input('formData'));
           if($res){
               return $this->create(200,'编辑成功');
           }else{
              return $this->create(100,'编辑失败');
           }
        }
    }


    public function housingList(){
        if (Request::has('keyWord')) {
            $whereStr = '';
            $limitStr = '';
            if (Request::input('pageSize') && Request::input('page')) {
                $limitStr =   limit_joint(Request::input('page'), Request::input('pageSize'));
            }
            $keyWord = array_filter(Request::input('keyWord'), 'filtrfunction');
            if (!empty($keyWord)) {
                $whereStr .= havaWhereLikeJoinEqual($keyWord);
            }
                $list  =   HousingDb::list($whereStr, $limitStr);
                $count =   HousingDb::count($whereStr);
                return $this->create(200, '查询成功', ['list' => $list, 'total' => $count[0]['count']]);
        }  else{
              return missingParameter();
        } 
    }

    public function housingAdminSelect(){
        return $this->create(200, '查询成功',  HousingDb::housingAdminSelect() );
    }

   
    public function housingTagList(){
        $res = HousingDb::housingTagList();
        return $this->create(200, '查询成功',$res?$res[0]:[]);
    }


    

}
